home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Plug-In Power Pack for Netscape Communicator
/
Plug-In Power Pack for Netscape Communicator.iso
/
plugins
/
dataviews
/
dvtools
/
demos
/
surfdemo
/
surftog.c
< prev
next >
Wrap
C/C++ Source or Header
|
1997-07-10
|
7KB
|
256 lines
#ifndef lint
static char SccsId[]= "@(#)surftog.c V1.8 3/17/95";
#endif
/*------------------------------------------------------------------
| file name -- surftog.c
|
| Functions related to the toggles that control the graph attibutes.
|
| functions Description
| --------- -----------
| InitToggleControls Initializes the toggle input objects
| HandleToggle Handles all events associated with the toggles
|
| toggle_context Toggles the context flag of the graph
| invert_graph Inverts the graph's data
| change_format Changes the type of graph being displayed
|
|-----------------------------------------------------------------*/
#include "std.h"
#include "dvstd.h"
#include "dvtools.h"
#include "VOstd.h"
#include "dvGR.h"
#include "Tfundecl.h"
#include "surfdata.h"
#include "dvinteract.h"
#include "VOfundecl.h"
#include "VPfundecl.h"
#include "VUerfundecl.h"
#include "surffundecl.h"
GLOBALREF DISPFORM VDsize, VD3dsurface, VDcontour, VDfcontour;
/* ------------------------------------------------------------------- */
/* Declare information for the toggle objects that set graph attributes */
/* ------------------------------------------------------------------- */
#define NUM_TOGGLES 4
#define COLOR_TOGGLE 0
#define CONTEXT_TOGGLE 1
#define INVERT_TOGGLE 2
#define FORMAT_TOGGLE 3
/* Strings to replace defaults set in DV-Draw */
LOCAL CHAR
* ColorStr[]=
{"Change\nColor"}, *ContextStrs[]=
{"Context\nON", "Context\nOFF"}, *InvertStrs[]=
{"Not\nInverted", "Inverted"}, *FormatStrs[]=
{"Surface\nPlot", "Size\nEncoding",
"Contour", "Filled\nContour"},
/* NOTE: Toggle Names can't start with a HandlePickEvent name, i.e:
QUIT_COMMAND - Q, FORMULA_COMMAND - F, ZRANGE_COMMAND - Z, PLOT_COMMAND - P,
THRESHOLD_COMMAND - T
*/
*ToggleName[]=
{"ChangeColor", "ChangeContext", "Invert", "ChangeFormat"}, **ToggleStr[]=
{ColorStr, ContextStrs, InvertStrs, FormatStrs};
LOCAL INT ToggleSize[NUM_TOGGLES] =
{1, 2, 2, 4};
LOCAL OBJECT ToggleInput[NUM_TOGGLES];
LOCAL INT
ContextVal = 1, ColorVal;
LOCAL ADDRESS ToggleBuffer[NUM_TOGGLES] =
{
(ADDRESS) & ColorVal,
(ADDRESS) & ContextVal,
(ADDRESS) & Plot.inverted,
(ADDRESS) & Plot.format
};
LOCAL INT ToggleType[NUM_TOGGLES] =
{
V_L_TYPE,
V_L_TYPE,
V_F_TYPE,
V_L_TYPE
};
/***************** Begin Function Declarations *************/
LOCAL void toggle_context V_P_((void));
LOCAL void invert_graph V_P_((void));
LOCAL void change_format V_P_((void));
/***************** End Function Declarations *************/
/*------------------------------------------------------------------
|
| InitToggleControls
| This function initializes each toggle. The label of the toggle
| is set, its vdp is rebound and a service function is posted.
*/
void InitToggleControls
V_P_ ((void))
{
INT i;
OBJECT it;
VARDESC vdp;
/* Setup the Input Toggles */
for (i = 0; i < NUM_TOGGLES; i++)
{
ToggleInput[i] = VOdrGetNamedObject (MainDrawing, ToggleName[i]);
/* DV-Draw does not let you specify a string with a carriage return,
| so we must modify some of the input object strings.
*/
it = VOinTechnique (ToggleInput[i], DONT_SET_THE_VALUE);
VOitPutList (it, TEXT_LIST, (ADDRESS) ToggleStr[i], ToggleSize[i]);
/* Rebind the data */
vdp = GetVdp (ToggleInput[i]);
(VOID) TvdPutBuffer (vdp, ToggleBuffer[i]);
VPvdtype (vdp, ToggleType[i]);
/* Setup the Service Functions */
(VOID) VUerServiceResultPost ((OBJECT) i, HandleToggle,
(ADDRESS) NULL, 0,
ToggleInput[i], INPUT_ACCEPT, i);
}
}
/*------------------------------------------------------------------
|
| HandleToggle
| This function handles events associated with the toggles.
*/
/* ARGSUSED */
int
HandleToggle (client, request, toggle_type, loc, argptr)
OBJECT client; /* Client initiating the call */
EVENT_REQUEST request; /* Event request triggering the call */
int toggle_type; /* Label from service result post */
OBJECT loc; /* Current location object */
ADDRESS argptr; /* User arguement block */
{
switch (toggle_type)
{
case COLOR_TOGGLE:
DrawColorControls (); /* found in surfcolor.c */
break;
case CONTEXT_TOGGLE:
toggle_context ();
break;
case INVERT_TOGGLE:
invert_graph ();
break;
case FORMAT_TOGGLE:
change_format ();
break;
default:
break;
}
return INPUT_ACCEPT;
}
/*------------------------------------------------------------------
|
| toggle_context
| This function toggles the graph's context flag.
*/
LOCAL void toggle_context
V_P_ ((void))
{
if (ContextVal == 1)
/* Turn context on in datagroup */
VPdgcontext (GraphDgp, V_FCONTEXT, 1);
else
/* Turn context off in datagroup */
VPdgcontext (GraphDgp, V_FCONTEXT, 0);
}
/*------------------------------------------------------------------
|
| invert_graph
| This function inverts the thresholds associated with the graph.
*/
LOCAL void invert_graph
V_P_ ((void))
{
FLOAT temp;
INT i;
SHORT tempupper;
/* Change the threshold values */
for (i = 0; i < 3; i++)
ThreshValue[i] *= -1.0;
temp = ThreshValue[2];
ThreshValue[2] = ThreshValue[0];
ThreshValue[0] = temp;
/* Change the man and max of the data */
temp = Formula.zmin;
Formula.zmin = Formula.zmax * -1.0F;
Formula.zmax = temp * -1.0F;
(VOID) S_SPRINTF (TextStr[ZMIN_INPUT], "%.6g", Formula.zmin);
(VOID) S_SPRINTF (TextStr[ZMAX_INPUT], "%.6g", Formula.zmax);
if (Plot.automaticz == NO)
{
(VOID) TdpDrawNextObject (MainDrawport, TextInput[ZMAX_INPUT]);
(VOID) TdpDrawNextObject (MainDrawport, TextInput[ZMIN_INPUT]);
}
/* Update the threshold tables */
tempupper = ThreshTable[0].upperlimit;
ThreshTable[0].upperlimit = 32767 - ThreshTable[2].upperlimit;
ThreshTable[1].upperlimit = 32767 - ThreshTable[1].upperlimit;
ThreshTable[2].upperlimit = 32767 - tempupper;
DrawThreshRect (ThreshEchoArea);
}
/*------------------------------------------------------------------
|
| change_format
| This function switches the graph type.
*/
LOCAL void change_format
V_P_ ((void))
{
DISPFORM graph_type;
DV_BOOL on_off_flag;
/* Determine the graph attributes base on the format type */
switch (Plot.format)
{
case SIZE:
graph_type = VDsize;
on_off_flag = (DV_BOOL) NO;
break;
case SURFACE:
graph_type = VD3dsurface;
on_off_flag = (DV_BOOL) YES;
break;
case CONTOUR:
graph_type = VDcontour;
on_off_flag = (DV_BOOL) YES;
break;
case FILLED_CONTOUR:
graph_type = VDfcontour;
on_off_flag = (DV_BOOL) YES;
break;
default:
break;
}
/* Set the graph attributes */
VPdgdf (GraphDgp, graph_type);
VPdgcontext (GraphDgp, V_FV_TICS | V_FV_LABEL_TICS, on_off_flag);
}